package com.travel.controller;

import com.travel.result.Result;
import com.travel.service.impl.CityInfoServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author:Jasenon_ce
 * Date: 2025.05.29/下午5:09
 */
@RestController
@RequestMapping("/city")
public class CityInfoController {

    @Autowired
    private CityInfoServiceImpl cityInfoService;

    @Autowired
    private List<String> supportedCities;

    @ApiOperation(value = "获取城市信息")
    @GetMapping("/info")
    public Result getCityInfo(@RequestParam("city_name") String cityName){
        if (supportedCities.contains(cityName)){
            return Result.success(cityInfoService.getCityInfoByCityName(cityName));
        }
        return Result.error("不支持的城市");
    }

    @ApiOperation(value = "获取所有支持的城市")
    @GetMapping("/supported")
    public Result getSupportedCities(){
        return Result.success(supportedCities);
    }

}
